/**
 * @简单的表达式求值
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	float value1, value2;
	char c;

	printf("请输入一个表达式：");
	scanf("%f %c %f", &value1, &c, &value2);

	switch (c) {
		case '+':
			  printf("%.2f \n", value1 + value2);
			  break;
		case '-':
			  printf("%.2f \n", value1 - value2);
			  break;
		case '*':
			  printf("%.2f \n", value1 * value2);
			  break;
		case '/':
			  if (value2 == 0) {
				printf("结果是0\n");
			  } else {
				printf("%.2f \n", value1 / value2);
			  }
			  break;
		default:
			  printf("输入符有误\n");
			  break;
	}

	return 0;
}
